package com.wangjiyuan.giftshuo.ui.fragment.classify.strategy;

import com.wangjiyuan.giftshuo.bean.classifybean.strategy.ColumnBean;
import com.wangjiyuan.giftshuo.bean.classifybean.strategy.GroupBean;
import com.wangjiyuan.giftshuo.config.classify.ClassifyURL;
import com.wangjiyuan.giftshuo.http.classityretrofitinterface.RetrofitInterface;
import com.wangjiyuan.giftshuo.utils.OkHttp3Helper;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.Observable;

/**
 * Created by QXL on 2016/11/15.
 */

public class StrategyModel implements StrategyContract.IStrategyModel {
//    获取品类、风格、对象数据
    @Override
    public Observable<GroupBean> getGroupObservable() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(ClassifyURL.BASE_URL)
                .client(OkHttp3Helper.getOkHttpSingletonInstance())
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
        RetrofitInterface retrofitInterface = retrofit.create(RetrofitInterface.class);
        Observable<GroupBean> groupObservable = retrofitInterface.getGroupObservable("channel_groups", "all");
        return groupObservable;
    }

//    获取栏目数据
    @Override
    public Observable<ColumnBean> getColumObservable() {
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl(ClassifyURL.BASE_URL)
                .client(OkHttp3Helper.getOkHttpSingletonInstance())
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
        RetrofitInterface retrofitInterface = retrofit.create(RetrofitInterface.class);
        Observable<ColumnBean> columObservable = retrofitInterface.getColumObservable();
        return columObservable;
    }
}
